﻿package baidu.reader.common.model
{
    import baidu.reader.common.*;
    import baidu.reader.common.model.VO.*;
    import flash.events.*;

    public class AppPreferenceModel extends EventDispatcher
    {
        private var _displayType:String;
        private var _fontName:String = "宋体";
        private var _fontSize:int = 14;
        private var _leading:int = 12;
        private var _currentPreference:AppPreferenceVO;

        public function AppPreferenceModel(param1:IEventDispatcher = null)
        {
            super(param1);
            this._currentPreference = LocalStorageModel.getCurrentPreference();
            if (this._currentPreference)
            {
                this._displayType = this._currentPreference.displayType;
                this._fontName = this._currentPreference.fontName;
                this._fontSize = this._currentPreference.fontSize;
                this._leading = this._currentPreference.leading;
            }
            return;
        }// end function

        public function get displayType() : String
        {
            return this._displayType;
        }// end function

        public function set displayType(param1:String) : void
        {
            if (this._displayType == param1 && !param1)
            {
                return;
            }
            this._displayType = param1;
            dispatchEvent(new ReaderEvent(ReaderEvent.DISPLAY_TYPE_CHANGED));
            this._currentPreference = AppPreferenceVO.getVOfromObject(this);
            LocalStorageModel.setCurrentPreference(this._currentPreference);
            return;
        }// end function

        public function get fontName() : String
        {
            return this._fontName;
        }// end function

        public function set fontName(param1:String) : void
        {
            if (this._fontName == param1 && !param1)
            {
                return;
            }
            this._fontName = param1;
            this._currentPreference = AppPreferenceVO.getVOfromObject(this);
            LocalStorageModel.setCurrentPreference(this._currentPreference);
            return;
        }// end function

        public function get fontSize() : int
        {
            return this._fontSize;
        }// end function

        public function set fontSize(param1:int) : void
        {
            if (this._fontSize == param1)
            {
                return;
            }
            this._fontSize = param1;
            this._currentPreference = AppPreferenceVO.getVOfromObject(this);
            LocalStorageModel.setCurrentPreference(this._currentPreference);
            return;
        }// end function

        public function get leading() : int
        {
            return this._leading;
        }// end function

        public function set leading(param1:int) : void
        {
            if (this._leading == param1)
            {
                return;
            }
            this._leading = param1;
            this._currentPreference = AppPreferenceVO.getVOfromObject(this);
            LocalStorageModel.setCurrentPreference(this._currentPreference);
            return;
        }// end function

    }
}
